package com.yuanzong.wuliu.controller.admin.business.customer;

import com.yuanzong.wuliu.common.vo.ApiResult;
import com.yuanzong.wuliu.controller.admin.business.customer.param.AdminBusinessCustomerAddParam;
import com.yuanzong.wuliu.controller.admin.business.customer.param.AdminBusinessCustomerEnableOrDisableParam;
import com.yuanzong.wuliu.controller.admin.business.customer.param.AdminBusinessCustomerModifyParam;
import com.yuanzong.wuliu.controller.admin.business.customer.param.AdminBusinessCustomerPageParam;
import com.yuanzong.wuliu.service.admin.business.customer.AdminBusinessCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@Api(tags = "管理端 - 客户")
@RequestMapping("/admin/business/customer/businessCustomer")
@Slf4j
public class AdminBusinessCustomerController {

    @Autowired
    private AdminBusinessCustomerService adminBusinessCustomerService;

    @ApiOperation("分页")
    @RequestMapping(value = "/page", method = {RequestMethod.POST})
    public ApiResult page(@RequestBody AdminBusinessCustomerPageParam param) throws Exception {
        ApiResult result = adminBusinessCustomerService.page(param);
        return result;
    }

    @ApiOperation("添加")
    @RequestMapping(value = "/add", method = {RequestMethod.POST})
    public ApiResult add(@Valid @RequestBody AdminBusinessCustomerAddParam param) throws Exception {
        ApiResult result = adminBusinessCustomerService.add(param);
        return result;
    }

    @ApiOperation("修改")
    @RequestMapping(value = "/modify", method = {RequestMethod.POST})
    public ApiResult modify(@RequestBody AdminBusinessCustomerModifyParam param) throws Exception {
        ApiResult result = adminBusinessCustomerService.modify(param);
        return result;
    }

    @ApiOperation("启用或禁用")
    @RequestMapping(value = "/enableOrDisable", method = {RequestMethod.POST})
    public ApiResult enableOrDisable(@RequestBody AdminBusinessCustomerEnableOrDisableParam param) throws Exception{
        ApiResult result = adminBusinessCustomerService.enableOrDisable(param);
        return result;
    }
}
